#include <iostream>
using namespace std;
#include <vector>
int main(){
    // 1.读入数据
    int n, m,q;
    cin >> n >> m >> q;
    vector<vector<int>> array(n + 1, (vector<int>(m + 1)));
    for (int i = 1; i <= n;i++){
        for (int j = 1; j <= m;j++){
            scanf("%d", &array[i][j]);
        }
    }
    // 2.预处理二维数组求其前缀和
    vector<vector<int>> s(n + 1, (vector<int>(m + 1)));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            s[i][j] = s[i - 1][j] + s[i][j - 1] + array[i][j] - s[i - 1][j - 1];
        }
    }
    // 3.使用预处理的前缀和
    int x1 = 0, y1 = 0, y2 = 0,x2 = 0;
    while(q--){
        cin >> x1 >> y1 >> x2 >> y2;
        cout << s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
    }
    return 0;
}